package com.iwhalecloud.bss.kite.cucc.service.attr.handler;

import com.iwhalecloud.bss.kite.common.util.KiteStringUtils;
import com.iwhalecloud.bss.kite.cucc.common.constant.LocalKeyConsts;
import com.iwhalecloud.bss.kite.manager.inst.KiteAttr;
import com.iwhalecloud.bss.kite.manager.inst.KiteInst;
import com.iwhalecloud.bss.kite.service.attr.AttrData;
import com.iwhalecloud.bss.kite.service.attr.handler.AbstractAttrHandler;
import com.iwhalecloud.bss.kite.service.scene.attr.OperateInstAttrService;
import org.springframework.beans.factory.annotation.Autowired;

/** 业务支撑部门 */
public class BusiSupportDepAttrHandler extends AbstractAttrHandler<KiteInst, AttrData> {

  @Autowired OperateInstAttrService operateInstAttrService;

  @Override
  public void set(KiteAttr attr, KiteInst inst, String value, AttrData data) {
    super.set(attr, inst, value, data);

    // 业务支撑部门详细描述
    KiteAttr busiSupportDepDescAttr = inst.getAttr("210008022");
    if (KiteStringUtils.isNotBlank(value) && KiteStringUtils.equals(value, "1_0000151")) { // 其他
      busiSupportDepDescAttr.setShowType(LocalKeyConsts.PROD_ATTR_SHOW_TYPE_M);
    } else {
      busiSupportDepDescAttr.setShowType(LocalKeyConsts.PROD_ATTR_SHOW_TYPE_E);
      // 业务支撑部门详细描述值设为空
      operateInstAttrService.setAttrValue(
          inst, "210008022", null, data.getSceneInstId(), null);
    }
  }
}
